package dk.jagtogjaeger.domain;

import java.util.Collection;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

public class Controller {

	private DBFacade dbFacade = null;
	GPSManager gpsManager = null;

	public Controller(Context context) {
		dbFacade = DBFacade.getInstance(context);
	}

	public boolean createJournal(HuntJournal journal) {
		return dbFacade.createJournal(journal);
	}

	public boolean updateJournal(HuntJournal journal) {
		return dbFacade.updateJournal(journal);
	}

	public boolean deleterJournal(HuntJournal journal) {
		return dbFacade.deleterJournal(journal);
	}

	public Collection<HuntJournal> getJournals() {
		return dbFacade.getJournals();
	}

	public String[] getSpeciesArray() {
		return dbFacade.getSpeciesArray();

	}

	private Collection<TrackerDog> fetchAllTrackerDogs() {
		return dbFacade.fetchAllTrackerDogs();
	}

	public void getLocation(Context context, Context baseContext, LocationListener ll) {
		gpsManager = new GPSManager();
		gpsManager.getLocation(context, baseContext, ll);
		
	}
	public void closeManager(LocationListener ll){
		gpsManager.closeManager(ll);
		gpsManager = null;
	}
	public String getMunicipality(Location location, Context baseContext) {
		return gpsManager.getMunicipality(location, baseContext);
	}
	
	public Collection<TrackerDog> getTrackerDogsWithDistance(Location location, Context baseContext){
		return gpsManager.getTrackerDogsWithDistance(location, baseContext, fetchAllTrackerDogs());	
	}
	

}
